package com.example.tool.fragment;

import com.example.tool.R;
import com.example.tool.dao.entity.HealthIndexDomain;
import com.example.tool.mvp.base.IBaseView;
import com.example.tool.util.ValueUtils;

import java.util.List;


/**
 * Created by liangkun on 2018/8/8.
 * 作用:体征统计
 */

public class SignsCountFragment extends BaseCountFragment implements IBaseView {
    @Override
    protected void initData() {
        super.initData();
        //图片
        taskImages = new int[]{R.mipmap.iv_record_weight, R.mipmap.iv_item_rhr, R.mipmap.iv_blood_pressure};
        countTags = getResources().getStringArray(R.array.sign_count_tag);
        countHints = getResources().getStringArray(R.array.sign_count_hint);

    }


    @Override
    protected void initView() {
        super.initView();
        tvTabIndex.setText(getString(R.string.body_num));


    }

    @Override
    protected void lazyLoad() {

    }

    @Override
    protected void initEvent() {
        barChartView.setOnScaleChangeListener(scale -> {
            tvCountIndex.setText(String.valueOf(indexList.get((int) scale)));
//            tvFinishCount.setText(String.valueOf(taskList.get((int) scale)));
            tvKeepDays.setText(String. valueOf(daysList.get((int) scale)));
        });
    }

    /**
     * 设置
     *
     * @param indexVos 数据
     */
    @Override
    protected void setBarData(List<HealthIndexDomain> indexVos) {
        indexList.clear();
        taskList.clear();
        daysList.clear();
        barList.clear();
//        taskFinishVos.clear();
        for (HealthIndexDomain domain : indexVos) {
//            int taskTotalFinish = 0;
            //指数
            int score = domain.getBody();
            indexList.add(score);
            barList.add(score / ValueUtils.BAR_BODY_SAORE);
            //累积时间
            int keepTime = domain.getBodyDays();
            daysList.add(keepTime);
            //完成任务个数o
//            String taskFinish = domain.getTaskFinish();
//            HeahthTaskFinishVo taskFinishVo = GsonUtil.fromJson(taskFinish, HeahthTaskFinishVo.class);
//            if (taskFinishVo != null) {
//                //睡眠
//                if (taskFinishVo.getBody() != null) {
//                    taskTotalFinish = taskFinishVo.getBody().getCount();
//                }
//                taskList.add(taskTotalFinish);
//                taskFinishVos.add(taskFinishVo);
//            }
        }
        barChartView.setData(barList);
        barChartView.setCurrent(29);
        setBarPoint();
//        countRecyclerAdapter = new CountRecyclerAdapter(getContext(), taskImages, countTags, countHints, taskFinishVos.get(29), 3);
//        recyclerView.setAdapter(countRecyclerAdapter);
//        dismissLoadingDialog();
    }
}
